package com.neusoft.Shixun.service.impl;

import com.neusoft.Shixun.dao.ClientDao;
import com.neusoft.Shixun.po.Client;
import com.neusoft.Shixun.service.ChatService;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChatServiceImpl implements ChatService {

    @Autowired
    public ClientDao clientDao;


    @Tool(description = "美食")
    @Override
    public String test() {
        return "鱼香肉丝";
    }

    @Override
    @Tool(description = "查询所有老人")
    public String test2() {
        List<Client> list = clientDao.selectList(null);
        if (list == null || list.isEmpty()) {
            System.out.println("没有查询到任何数据！");
            return "没有查询到任何数据！";
        }

        StringBuilder result = new StringBuilder();
        for (Client client : list) {
            if (client == null || client.toString() == null || client.toString().isEmpty()) {
                System.out.println("Client 对象或其 toString 方法返回为空！");
                continue;
            }
            result.append(client.toString());
            result.append("\n");
        }

        if (result.toString().isEmpty()) {
            System.out.println("结果为空！");
            return "结果为空！";
        }

        return result.toString();
    }


}
